﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Test.Utility.Extensions
{
    public static class ArrayExtensions
    {
        //转为简单的json字符串
        public static string ToJsonString<T>(this T[] source, bool needBracket = true)
        {
            string result = "";
            for (int i = 0; i < source.Length; i++)
            {
                if (i != 0)
                {
                    result += ",";
                }
                result += source[i];
            }

            if (needBracket)
            {
                return "[" + result + "]";
            }
            else
            {
                return result;
            }
        }
    }
}
